package com.amigo.online.provider.common.util;

import com.amigo.online.common.param.dto.video.AreaDto;
import com.amigo.online.common.param.result.AreaInfo;
import com.amigo.online.common.param.result.GlobalConfigInfo;
import com.amigo.online.provider.common.model.entity.Area;
import com.amigo.online.provider.common.model.entity.BusiArea;
import com.amigo.online.provider.common.model.entity.GlobalConfig;

public class ConvertUtil {

    public static GlobalConfigInfo GlobalConfigToGlobalConfigInfo(GlobalConfig gc) {
        if (gc == null) {
            return null;
        }

        GlobalConfigInfo info = new GlobalConfigInfo();
        info.setId(gc.getId().intValue());
        info.setKeyname(gc.getKeyname());
        info.setValue(gc.getValue());
        return info;
    }

    public static AreaInfo AreaToAreaInfo(Area area, String lang) {
        if (area == null) {
            return null;
        }
        AreaInfo info = new AreaInfo();
        info.setId(area.getId().intValue());
        info.setPid(area.getPid());
        info.setLevel(area.getLevel());
        if (lang.equals("chinese")) {
            info.setName(area.getChinese());
        }
        if (lang.equals("english")) {
            info.setName(area.getEnglish());
        }
        if (lang.equals("portuguese")) {
            info.setName(area.getPortuguese());
        }
        if (lang.equals("spanish")) {
            info.setName(area.getSpanish());
        }
        return info;
    }


    public static AreaInfo BusiAreaToAreaInfo(BusiArea busiArea, AreaDto dto) {
        if (busiArea == null) {
            return null;
        }
        AreaInfo info = new AreaInfo();
        info.setId(busiArea.getId().intValue());
        info.setPid(busiArea.getPid());
        info.setLevel(busiArea.getLevel());
        String lang = dto.getLang();
        String phoneType = dto.getPhoneType();
        if ("IOS".equals(phoneType)) {
            if (lang.equals("chinese")) {
                info.setName(busiArea.getIChinese());
            }
            if (lang.equals("english")) {
                info.setName(busiArea.getIEnglish());
            }
            if (lang.equals("portuguese")) {
                info.setName(busiArea.getIPortuguese());
            }
            if (lang.equals("spanish")) {
                info.setName(busiArea.getISpanish());
            }
        } else {
            if (lang.equals("chinese")) {
                info.setName(busiArea.getAChinese());
            }
            if (lang.equals("english")) {
                info.setName(busiArea.getAEnglish());
            }
            if (lang.equals("portuguese")) {
                info.setName(busiArea.getAPortuguese());
            }
            if (lang.equals("spanish")) {
                info.setName(busiArea.getASpanish());
            }
        }
        return info;
    }
}
